//*****************************************************************************
// JFab (http://code.google.com/p/jfab)
// Copyright (c) 2011-2012 JFab.org
// Admin jfab@jeffreythompson.net
//
// See the file "LICENSE.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//*****************************************************************************

package org.jfab.swingui.editpane;

import javax.swing.JTextField;

import org.jfab.core.model.CGEnumItem;

/**
 * Provides an edit pane for a code generator enum item.
 */
public final class CGEnumItemEditPane extends CGObjectEditPane<CGEnumItem>
{
    /** Serial version UID. */
    private static final long serialVersionUID = 1L;

    /** Parameters widget. */
    private JTextField _parametersUI;

    /**
     * @param cgEnumItem Code generator enum item.
     */
    public CGEnumItemEditPane(final CGEnumItem cgEnumItem)
    {
        super(cgEnumItem);
    }

    @Override
    public final void applyChanges()
    {
        super.applyChanges();

        final CGEnumItem subject = getSubjectObject();

        subject.setParameters(_parametersUI.getText());
    }

    @Override
    protected final void createWidgets()
    {
        super.createWidgets();

        _parametersUI = createTextField();
    }

    @Override
    protected final void fillPanel()
    {
        super.fillPanel();

        bindAndAdd("parameters", _parametersUI);
    }

    @Override
    protected final void fillWidgets()
    {
        super.fillWidgets();

        final CGEnumItem subject = getSubjectObject();

        _parametersUI.setText(subject.getParameters());
    }
}
